package br.com.salao.model;

import java.util.List;
import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;

import org.apache.log4j.Logger;

import br.com.salao.entity.EtapasConfiguracaoEstabelecimento;
import br.com.salao.session.EtapasConfiguracaoEstabelecimentoBase;
import br.com.salao.util.Utils;

public class EtapasConfiguracaoEstabelecimentoModel {
	
	/**
	 * @author Adriana Del Nero
	 */

	private Logger logger =  Logger.getLogger(EstadoModel.class.getName());

	public List<EtapasConfiguracaoEstabelecimento> listar(){
		try {	
			EtapasConfiguracaoEstabelecimentoBase etapasConfiguracaoEstabelecimentoBase = getBean();
			return etapasConfiguracaoEstabelecimentoBase.listar();
		} catch (Exception e) {

			StringBuffer sb = new StringBuffer();
			sb.append(e.getMessage() + "\n");
			sb.append(e.getStackTrace());
			logger.debug(sb.toString());

			return null;
		}
	}
	
    public EtapasConfiguracaoEstabelecimentoBase getBean() throws Exception {
    	
        Properties prop = Utils.getProperties();     
        Context ctx = new InitialContext(prop); 
        Object ref = ctx.lookup(prop.getProperty("ETAPASCONFIGURACAO_LOOKUP"));       
      
        return (EtapasConfiguracaoEstabelecimentoBase)PortableRemoteObject.narrow(ref, EtapasConfiguracaoEstabelecimentoBase.class);
    }
}
